package com.example.rk.kaptcha;

import com.google.code.kaptcha.Constants;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController

public class login {

    @GetMapping("login")

    public boolean login(HttpServletRequest request, @RequestParam("code") String code) {
        String sessionCode = (String) request.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY);
        if (code.equals(sessionCode)) {
//            验证正常返回true
            return true;
        } else {
//            验证失败返回false
            return false;
        }

    }
}

